package com.china_goldcard.igas.utils;

import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * Created by jk on 16/10/10.
 */

public class DateUtils {

    /**
     * 转换成字符串
     * @param date
     * @param pattern
     * @return
     */
    public static String dateToStr(Date date, String pattern){
        return new SimpleDateFormat(pattern).format(date);
    }

    /**
     * 字符串转换成Date对象
     * @param dateStr
     * @param pattern
     * @return
     */
    public static Date strToDate(String dateStr, String pattern){
        try {
            return new SimpleDateFormat(pattern).parse(dateStr);
        }catch (Exception ex){
            return null;
        }
    }

}
